<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCallnameStudentsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create($this->tableName, function(Blueprint $table){
            $table->increments('id');

            $table->string('name', 20);
            $table->string('number', 12);

            $table->unsignedInteger('student_id')->nullable();

            $table->unsignedInteger('callname_list_id');
            $table->foreign('callname_list_id')->references('id')->on('callname_lists')->onDelete('cascade');

            $table->integer('absent_times')->default(0);

            $table->timestamps();
        });
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop($this->tableName);
	}

    private $tableName = 'callname_students';
}
